<?php
/**
 *
 * @author petranachbaur
 */
class MenuHelper {
 
    static private function getRequestBaseSegment(){
        $request = Yii::app()->getRequest();

        $path = $request->getPathInfo();

        $dividedPath = explode('/', $path);
        return $dividedPath[0];        
    }
    
        
    static public function getArrayForCoreDataMenu() {
        $menuEntries = array(
            array('label'=>'Kursvorlagen', 'url'=>'coursetemplate'),

            array('label'=>'Kategorien', 'url'=>'category'),

            array('label'=>'Zentralen', 'url'=>'central'),

            array('label'=>'Kursart', 'url'=>'type'),

            array('label'=>'Kursstatus', 'url'=>'status'),

            array('label'=>'Kursabschluss', 'url'=>'graduation'),

            array('label'=>'Unterrichtszeiten', 'url'=>'classTime'),
            
            array('label'=>'AMS/FAB Betreuer', 'url'=>'advisor'),
            
            array('label'=>'AMS', 'url'=>'ams'),
            
            array('label'=>'Mitarbeiter', 'url'=>'staff'),
            
            array('label'=>'Kundenstatus', 'url'=>'userStatus'),
            
            array('label'=>'Bildungspartner', 'url'=>'partner'),
        );
 
        $menuArray = Array();
        $i = 0;

        foreach ($menuEntries as $entry) {

            $label = $entry['label'];
            $url = '/' . $entry['url'] . '/admin';
            $active = ($entry['url'] == MenuHelper::getRequestBaseSegment());
            $menuArray[$i] = array('label' => $label, 'url' => array($url), 'active'=>$active);
            $i++;
        }

       return $menuArray;
    }
    
    static public function getArrayForMainMenu($user, $course, $trainer, $core_data=false) {
//        return array(
//            array(
//                'class'=>'bootstrap.widgets.TbMenu',
//                'items'=>
            return array(
                    array('label'=>'Kunden', 'url'=>array('/user/admin'), 'active'=>$user),
                    array('label'=>'Kurse', 'url'=>array('/course/admin'), 'active'=>$course),
                    array('label'=>'Trainer', 'url'=>array('/trainer/admin'), 'active'=>$trainer),
                    array('label'=>'Stammdaten', 'url'=>array('/coursetemplate/admin'), 'active'=>$core_data),
//                    MenuHelper::getArrayForCoreDataMenu(),
//                ),
//            ),
//            array(
//                'class'=>'bootstrap.widgets.TbMenu',
//                'htmlOptions'=>array('class'=>'pull-right'),
//                'items'=>array(
//                    array('label'=>'Bedienungshilfen', 'url'=>'#', 'items'=>  MenuHelper::getArrayForCoreDataMenu()),
//                ),
//            ),
        );
    }

}

?>
